<script setup lang="ts">

import {ref, onMounted} from 'vue'
import { Search,ArrowDown } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { ElTable } from 'element-plus'
import { ElButton, ElDialog } from 'element-plus'
import router from '@/router'
import { GetUser } from "@/utils/lStorage"

import {apiConfigCreate} from '@/api/api'
import {backTo} from '@/utils/jump'


const createParmas =ref({
	Name: "",
	Desc:"",
	Config:""
})

async function handlerConfigCreate() {
	if (!createParmas.value.Name){
      ElMessage.error("请输入配置名称")
      return 
	}
	if (!createParmas.value.Config){
      ElMessage.error("请输入配置")
      return 
	}
  

  const data = await apiConfigCreate(createParmas.value)
  if (data.CODE != "ok") {
      console.log(data)
      ElMessage.error("执行失败， 请联系管理员")
      return 
  }

  ElMessage({
    message: '创建成功',
    type: 'success',
  })
  backTo()
  return 

}

</script>

<template>
	<div class="info_box">
		
  <el-form :model="createParmas" label-width="120px">
    <el-form-item label="配置名称">
      <el-input v-model="createParmas.Name" clearable/>
    </el-form-item>

	<el-form-item label="说明">
      <el-input v-model="createParmas.Desc"     
      	autosize
      	clearable
    	type="textarea"
    	placeholder="配置说明"/>
    </el-form-item>

	<el-form-item label="配置内容">
		<el-input v-model="createParmas.Config"     
      	:rows="30"
    	type="textarea"
    	placeholder="配置内容"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="handlerConfigCreate">提交</el-button>
    </el-form-item>
   </el-form>
	</div>


</template>